import response from '@/utils/response';
import { setToken } from '@/utils/token';
import { GET_TOKEN, CLEAR_TOKEN } from '../constants';
/**获取token */
export const loginToken = (data) => {
  return async (dispatch) => {
    const {
      data: {
        data: { token },
      },
    } = await response.post('/authorizations', data);
    setToken(token);
    dispatch({
      type: GET_TOKEN,
      payload: token,
    });
  };
};

/**清空token */
export const clearToken = () => ({
  type: CLEAR_TOKEN,
});
